package com.example.onviftemp3

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.pqtel.libonvif.LibOnvif
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    private val TAG = javaClass.simpleName
    val ip = "192.168.0.25"
    var libOnvif:LibOnvif = LibOnvif()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        libOnvif.init("admin","123456",ip)
        // Example of a call to a native method
//        sample_text.text =

        btnUp.setOnClickListener {
            libOnvif.doPtz(ip,4,10f)
        }
        btnLeft.setOnClickListener {
            libOnvif.doPtz(ip,6,10f)
        }
        btnRight.setOnClickListener {
            libOnvif.doPtz(ip,7,10f)
        }
        btnDown.setOnClickListener {
            libOnvif.doPtz(ip,5,10f)
        }
        btnStop.setOnClickListener {
            libOnvif.doPtzStop(ip)
//            libOnvif.setTokenByUri(ip," rtsp://192.168.0.25:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif")
        }
        btnGet.setOnClickListener {
            val url = libOnvif.getOnvifMediaUri(ip)
            Log.d(TAG, "onCreate: url:$url")
        }
    }

}
